Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] Add global loading indicator for long running tasks #8611

Merged
merged 9 commits into from
Mar 20, 2023

Conversation

JammingBen
Copy link
Contributor

@JammingBen JammingBen commented Mar 15, 2023

Description

Adds a global loading indicator for long running actions at the top of the page.

How to use it (for devs)

Simply wrap your Promise in the addTask method provided by the loadingService:

loadingService.addTask(() => {
  return new Promise((resolve, reject) => {
    resolve(true)
  })
})

The method also provides a callback setProgress which can be used to update the progress of a task.

loadingService.addTask((setProgress) => {
  const promises = []
  const actions = [1, 2, 3, 4, 5]

  for (const [i, action] of actions.entries()) {
    promises.push(
      new Promise((resolve, reject) => {
        setProgress({ total: actions.length, current: i + 1 })
        resolve(true)
      })
    )
  }

  return Promise.all(promises)
}, { indeterminate: false })

The following options can be provided to addTask:

  • debounceTime - Time until the loading state for a task is set active. Defaults to 200 ms
  • indeterminate - Determines if the task is in an indeterminate state. Defaults to true.

Note that the loading bar won't show a progress when at least one task is in an indeterminate state.

Thx to @dschmidt for helping me out with the task adding & handling!

Video

loadingBar.mov

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

@JammingBen JammingBen self-assigned this Mar 15, 2023
@update-docs
Copy link

update-docs bot commented Mar 15, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@JammingBen JammingBen force-pushed the global-loading-indicator branch from 834db33 to f42a82a Compare March 15, 2023 06:49
@ownclouders
Copy link
Contributor

ownclouders commented Mar 15, 2023

Results for acceptance oC10 https://drone.owncloud.com/owncloud/web/33666/32/1

💥 The acceptance tests failed on retry. Please find the screenshots inside ...

webUITrashbinDelete-trashbinDelete_feature-L110.png

webUITrashbinDelete-trashbinDelete_feature-L110.png

webUITrashbinDelete-trashbinDelete_feature-L123.png

webUITrashbinDelete-trashbinDelete_feature-L123.png

webUITrashbinDelete-trashbinDelete_feature-L36.png

webUITrashbinDelete-trashbinDelete_feature-L36.png

webUITrashbinDelete-trashbinDelete_feature-L85.png

webUITrashbinDelete-trashbinDelete_feature-L85.png

@JammingBen JammingBen changed the title Add global loading indicator for long running tasks [full-ci] Add global loading indicator for long running tasks Mar 15, 2023
@JammingBen JammingBen force-pushed the global-loading-indicator branch 2 times, most recently from b61393f to 4b7ecae Compare March 15, 2023 09:36
@JammingBen JammingBen marked this pull request as ready for review March 15, 2023 09:55
@JammingBen JammingBen requested review from kulmann and dschmidt March 15, 2023 09:55
Copy link
Member

@dschmidt dschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like where this is going - thanks for taking the time to try the "addTask approach" I suggested.

@tbsbdr
Copy link
Contributor

tbsbdr commented Mar 15, 2023

Visual improvement proposal

  • @JammingBen et al: movement catches our attention by itself; thus I'd propose to make the bar more decent; do you think this would be an improvement?
screenshot_000621.mp4

@JammingBen JammingBen force-pushed the global-loading-indicator branch from 42547e5 to 013998e Compare March 15, 2023 12:44
@JammingBen JammingBen force-pushed the global-loading-indicator branch 2 times, most recently from 3b8a325 to 9e70a19 Compare March 17, 2023 10:12
JammingBen added a commit that referenced this pull request Mar 17, 2023
JammingBen added a commit that referenced this pull request Mar 17, 2023
@JammingBen JammingBen force-pushed the global-loading-indicator branch from 81da650 to a2b7c91 Compare March 17, 2023 10:17
JammingBen added a commit that referenced this pull request Mar 17, 2023
@JammingBen JammingBen force-pushed the global-loading-indicator branch from a2b7c91 to c7e43de Compare March 17, 2023 10:34
@JammingBen JammingBen force-pushed the global-loading-indicator branch from c7e43de to e404ff6 Compare March 20, 2023 14:18
@sonarcloud
Copy link

sonarcloud bot commented Mar 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

71.2% 71.2% Coverage
2.3% 2.3% Duplication

return loadingService.addTask(
({ setProgress }) => {
return restoreResources(space, resolvedResources, missingFolderPaths, { setProgress })
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to destructure and build a new object, but not so important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Web] Add Loading Indicator [QA] Show progress bar when delete or rename takes longer
4 participants